package com.sxd.bill.common.enums;

import com.sxd.bill.common.exceptions.EnumConstantNotFoundException;

public enum LabelNameEnum {
    PUB_ORG("发布者所属机构", "publisherOrg"),
    DISCOUNTER("贴现人", "discounter"),
    ACCEPTOR("承兑人", "accpetor"),
    DUE_TIME("票据期限", "dueTime"),
    RATE("利率", "rate"),
    AMOUNT("金额", "amt"),
    BILL_TYPE("票据类型", "billType"),
    TRD_DIR("交易方向", "tradingDirection");

    private final String cnName;
    private final String enName;

    LabelNameEnum(String cnName, String enName) {
        this.cnName = cnName;
        this.enName = enName;
    }

    public String getCnName() {
        return cnName;
    }

    public String getEnName() {
        return enName;
    }

    public static LabelNameEnum fromCnName(String cnName) throws Exception {
        for (LabelNameEnum label : LabelNameEnum.values()) {
            if (label.getCnName().equals(cnName)) {
                return label;
            }
        }
        throw new EnumConstantNotFoundException("No matching enum constant found for cnName:" + cnName);
    }

    public static LabelNameEnum fromEnName(String enName) throws Exception {
        for (LabelNameEnum label : LabelNameEnum.values()) {
            if (label.getEnName().equals(enName)) {
                return label;
            }
        }
        throw new EnumConstantNotFoundException("No matching enum constant found for enName:" + enName);
    }

}
